package cn.lg.soar.flow.biz.entity;

import cn.lg.soar.core.annotations.constraints.group.Update;
import cn.lg.soar.database.base.entity.IBaseEntity;
import cn.lg.soar.flow.api.model.node.ButtonInfo;
import cn.lg.soar.flow.api.model.node.FieldInfo;
import cn.lg.soar.flow.api.model.node.Node;
import cn.lg.soar.flow.api.model.node.ProcessListener;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 流程版本
 * @author luguoxiang
 * @since 2025-08-02
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Data
@Schema(description = "流程版本")
@TableName(value = "lg_flow_process_version", autoResultMap = true)
public class SoarProcessVersion {

    /** 主键 */
    @NotNull(message = "主键不能为空", groups = { Update.class })
    @ExcelIgnore
    @Schema(description = "主键")
    @TableId(type = IdType.INPUT)
    private String id;

    /** 流程名称 */
    @Schema(description = "流程名称")
    public String name;

    /** 字段信息 */
    @Schema(description = "字段信息")
    public String titleTemplate;

    /** 字段信息 */
    @Schema(description = "字段信息")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<FieldInfo> fields;

    /** 按钮信息 */
    @Schema(description = "按钮信息")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<ButtonInfo> buttons;

    /** 监听器 */
    @Schema(description = "监听器")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<ProcessListener> listeners;

    @Schema(description = "节点信息")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<Node> nodes;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @Schema(description = "创建时间")
    @TableField(value = IBaseEntity.CREATE_TIME, fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    protected LocalDateTime createTime;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @TableField(value = IBaseEntity.CREATE_BY, fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    @Schema(description = "创建人")
    protected Long createBy;


}
